from typing import Any

class Node:

    def __init__(self, data: Any):
        self.data = data
        self.next = None


class CircularLinkedList(object):
    def __init__(self):
        self.head = None
        self.tail = None

    def __iter__(self):
        '''循环链表的对象是可迭代的'''
        node = self.head
        while self.head:
            yield node.data
            node = node.next
            if node == self.head:
                break

    def __len__(self) -> int:
        return len(tuple(iter(self)))

    def __repr__(self):
        '''重写方法 返回实例化对象信息  即迭代输出链表节点的值'''
        return "->".join(str(item) for item in iter(self))

    #7.5
    def len(self):
        if self.tail is None:
            return 0
        walk = self.tail.next
        count = 1
        while walk != self.tail:
            count += 1
            walk = walk.next
        return count
